<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
         function runAsync(x) {
            const p = new Promise(resolve => setTimeout(() => resolve(x, console.log(x)), 1000))
            return p
        }
        function runReject(x) {
            const p = Promise(
                (res, rej) => setTimeout(
                    () => rej(`Error: ${x}`, console.log(x)), 1000*x))
            return p
        }
        Promise.all([runAsync(1), runReject(4), runAsync(3), runReject(2)])
            .then(res => console.log(res))
            .then(res => console.log(err))
    </script>
</body>
</html>